<?php
namespace app\behaviors;
use yii\base\Behavior;

class Behavior1 extends Behavior{

    public $height;//如果将其定义为protect则注入以后的类，将不能调用
    public function eat(){

        echo 'dog eat';
    }

    public function events()
    {
        return [
            'wang' => 'shout'//wang的事件发生后，调用shout方法
        ];
    }

    public function shout($event)
    {
        echo "wang wang wang<br>";
    }
}